package com.woniuxy.commons.utils;

import com.woniuxy.service.dto.CommentAttentCreateDto;
import com.woniuxy.controller.form.CommentCreatForm;
import com.woniuxy.controller.form.OrderLogForm;
import com.woniuxy.service.dto.UserDetailsDto;
import org.springframework.security.core.context.SecurityContextHolder;


public class OrderLogUtil {

    public static OrderLogForm createOrderLog(String orderNum,Integer state,String operContent,
                                              String operReason,String operName){
        OrderLogForm orderLogForm=new OrderLogForm();
        String format1 = CommonsUtil.getOrderCreateTime();
        orderLogForm.setOrderNum(orderNum);
        orderLogForm.setOrderState(state);
        orderLogForm.setOperContent(operContent);
        orderLogForm.setOperDate(format1);
        orderLogForm.setOperReason(operReason);
        orderLogForm.setOperName(operName);
        UserDetailsDto userDetailsDto = (UserDetailsDto) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        orderLogForm.setOperUser(userDetailsDto.getUsername());
        return orderLogForm;
    }

    public static CommentCreatForm creatComment(Long storeId,String orderNum,Integer storeScore,Integer dishesScore,
                                                Integer dphScore,String content,Integer pictureFlag,
                                                String userPhoto,String user,String userName){

        CommentCreatForm commentCreatForm=new CommentCreatForm();
        commentCreatForm.setContent(content);
        commentCreatForm.setDate(CommonsUtil.getOrderCreateTime());
        commentCreatForm.setDeleted(0);
        commentCreatForm.setDishesScore(dishesScore);
        commentCreatForm.setDphScore(dphScore);
        commentCreatForm.setPictureFlag(pictureFlag);
        commentCreatForm.setOrderNum(orderNum);
        commentCreatForm.setReplay("无");
        commentCreatForm.setReplayFlag(0);
        commentCreatForm.setStoreId(storeId);
        commentCreatForm.setStoreScore(storeScore);
        commentCreatForm.setUser(user);
        commentCreatForm.setUserName(userName);
        commentCreatForm.setUserPhoto(userPhoto);
        return commentCreatForm;
    }

    public static CommentAttentCreateDto createCommentAttent(String oldFileName,String fileName,Long size,
                                                             String filePath,String fileSuffix){

        CommentAttentCreateDto commentAttentCreateDto=new CommentAttentCreateDto();
        commentAttentCreateDto.setCreateDate(CommonsUtil.getOrderCreateTime());
        commentAttentCreateDto.setFileName(fileName);
        commentAttentCreateDto.setFilePath(filePath);
        commentAttentCreateDto.setFileSuffix(fileSuffix);
        commentAttentCreateDto.setOldFileName(oldFileName);
        commentAttentCreateDto.setSize(size);
        return commentAttentCreateDto;
    }
}
